<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>外卖平台管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: #f5f5f5;
            color: #333;
        }
        
        .navbar {
            background: white;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            padding: 15px 0;
            position: sticky;
            top: 0;
            z-index: 100;
        }
        
        .nav-container {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
        }
        
        .nav-logo {
            font-size: 24px;
            font-weight: bold;
            color: #ff6b6b;
        }
        
        .nav-menu {
            display: flex;
            gap: 30px;
            align-items: center;
        }
        
        .nav-link {
            text-decoration: none;
            color: #333;
            font-weight: 500;
            padding: 10px 15px;
            border-radius: 5px;
            transition: all 0.3s ease;
        }
        
        .nav-link:hover, .nav-link.active {
            background: #ff6b6b;
            color: white;
        }
        
        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .btn {
            padding: 8px 16px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s ease;
        }
        
        .btn-primary {
            background: #ff6b6b;
            color: white;
        }
        
        .btn-primary:hover {
            background: #ee5a24;
        }
        
        .main-content {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        
        .section {
            display: none;
            background: white;
            border-radius: 10px;
            padding: 30px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        
        .section.active {
            display: block;
        }
        
        .section h2 {
            color: #333;
            margin-bottom: 20px;
            font-size: 28px;
        }
        
        .section p {
            color: #666;
            margin-bottom: 20px;
            line-height: 1.6;
        }
        
        .grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }
        
        .card {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 20px;
            border: 1px solid #e9ecef;
            transition: all 0.3s ease;
        }
        
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 20px rgba(0,0,0,0.1);
        }
        
        .card h3 {
            color: #333;
            margin-bottom: 15px;
        }
        
        .card p {
            color: #666;
            margin-bottom: 15px;
        }
        
        .login-prompt {
            text-align: center;
            padding: 60px 20px;
        }
        
        .login-prompt h2 {
            color: #333;
            margin-bottom: 20px;
        }
        
        .login-prompt p {
            color: #666;
            margin-bottom: 30px;
        }
        
        .login-buttons {
            display: flex;
            gap: 15px;
            justify-content: center;
            flex-wrap: wrap;
        }
        
        .btn-large {
            padding: 15px 30px;
            font-size: 16px;
        }
        
        .hidden {
            display: none;
        }
        
        .user-welcome {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px;
            border-radius: 10px;
            margin-bottom: 20px;
            text-align: center;
        }
        
        .user-welcome h2 {
            color: white;
            margin-bottom: 10px;
        }
        
        .user-welcome p {
            color: rgba(255,255,255,0.9);
        }
        
        .card-icon {
            font-size: 2.5rem;
            color: #ff6b6b;
            margin-bottom: 15px;
            text-align: center;
        }
        
        .card-stats {
            display: flex;
            gap: 15px;
            margin-top: 15px;
            flex-wrap: wrap;
        }
        
        .card-stats span {
            background: rgba(255, 107, 107, 0.1);
            color: #ff6b6b;
            padding: 5px 10px;
            border-radius: 15px;
            font-size: 12px;
            font-weight: 600;
        }
        
        .back-btn {
            position: fixed;
            top: 20px;
            left: 20px;
            background: rgba(255, 107, 107, 0.8);
            border: none;
            border-radius: 50%;
            width: 50px;
            height: 50px;
            cursor: pointer;
            color: white;
            font-size: 20px;
            transition: all 0.3s ease;
            z-index: 1000;
        }
        
        .back-btn:hover {
            background: #ff6b6b;
            transform: scale(1.1);
        }
    </style>
</head>
<body>
    <button class="back-btn" onclick="goBack()">←</button>
    
    <nav class="navbar">
        <div class="nav-container">
            <div class="nav-logo">
                🍽️ 外卖平台
            </div>
            <div class="nav-menu">
                <a href="#home" class="nav-link active" onclick="showSection('home')">首页</a>
                <a href="#user" class="nav-link" onclick="showSection('user')">用户端</a>
                <a href="#merchant" class="nav-link" onclick="showSection('merchant')">商家端</a>
                <a href="#rider" class="nav-link" onclick="showSection('rider')">骑手端</a>
                <div class="user-info" id="userInfo">
                    <span id="userName"></span>
                    <button class="btn btn-primary" onclick="logout()">退出</button>
                </div>
            </div>
        </div>
    </nav>

    <main class="main-content">
        <!-- 首页 -->
        <section id="home" class="section active">
            <div class="user-welcome" id="welcomeSection">
                <h2>欢迎使用外卖平台管理系统</h2>
                <p>为商家、用户、骑手提供一站式外卖服务解决方案</p>
            </div>
            
            <div class="grid">
                <div class="card">
                    <h3>👤 用户端</h3>
                    <p>浏览商家、点餐下单、查看订单状态</p>
                    <button class="btn btn-primary" onclick="showSection('user')">进入用户端</button>
                </div>
                <div class="card">
                    <h3>🏪 商家端</h3>
                    <p>管理菜品、处理订单、查看经营数据</p>
                    <button class="btn btn-primary" onclick="showSection('merchant')">进入商家端</button>
                </div>
                <div class="card">
                    <h3>🏍️ 骑手端</h3>
                    <p>接单配送、地图导航、查看收益</p>
                    <button class="btn btn-primary" onclick="showSection('rider')">进入骑手端</button>
                </div>
            </div>
        </section>

        <!-- 用户端 -->
        <section id="user" class="section">
            <div class="login-prompt" id="userLoginPrompt">
                <h2>用户端</h2>
                <p>请先登录以使用用户功能</p>
                <div class="login-buttons">
                    <button class="btn btn-primary btn-large" onclick="goToLogin()">登录</button>
                    <button class="btn btn-primary btn-large" onclick="goToRegister()">注册</button>
                </div>
            </div>
            
            <div id="userContent" class="hidden">
                <div class="user-welcome">
                    <h2>👤 用户端</h2>
                    <p>欢迎，<span id="userDisplayName"></span>！开始您的美食之旅</p>
                </div>
                
                <div class="grid">
                    <div class="card">
                        <div class="card-icon">🔍</div>
                        <h3>浏览商家</h3>
                        <p>发现附近的美食商家，浏览丰富的菜品选择</p>
                        <div class="card-stats">
                            <span>50+ 商家</span>
                            <span>1000+ 菜品</span>
                        </div>
                        <button class="btn btn-primary" onclick="goToUser()">进入用户中心</button>
                    </div>
                    <div class="card">
                        <div class="card-icon">🛒</div>
                        <h3>下单点餐</h3>
                        <p>选择心仪的菜品，一键下单，享受便捷服务</p>
                        <div class="card-stats">
                            <span>30分钟送达</span>
                            <span>多种支付</span>
                        </div>
                    </div>
                    <div class="card">
                        <div class="card-icon">📋</div>
                        <h3>订单管理</h3>
                        <p>实时跟踪订单状态，查看历史订单记录</p>
                        <div class="card-stats">
                            <span>实时跟踪</span>
                            <span>历史记录</span>
                        </div>
                    </div>
                    <div class="card">
                        <div class="card-icon">⭐</div>
                        <h3>评价反馈</h3>
                        <p>为您的用餐体验打分，帮助其他用户选择</p>
                        <div class="card-stats">
                            <span>好评如潮</span>
                            <span>真实评价</span>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- 商家端 -->
        <section id="merchant" class="section">
            <div class="login-prompt" id="merchantLoginPrompt">
                <h2>商家端</h2>
                <p>请先登录以使用商家功能</p>
                <div class="login-buttons">
                    <button class="btn btn-primary btn-large" onclick="goToLogin()">登录</button>
                    <button class="btn btn-primary btn-large" onclick="goToRegister()">注册</button>
                </div>
            </div>
            
            <div id="merchantContent" class="hidden">
                <div class="user-welcome">
                    <h2>🏪 商家端</h2>
                    <p>欢迎，<span id="merchantDisplayName"></span>！管理您的餐厅业务</p>
                </div>
                
                <div class="grid">
                    <div class="card">
                        <div class="card-icon">🍽️</div>
                        <h3>菜品管理</h3>
                        <p>添加、编辑、删除菜品，管理菜单和价格</p>
                        <div class="card-stats">
                            <span>添加菜品</span>
                            <span>编辑信息</span>
                        </div>
                        <button class="btn btn-primary" onclick="goToMerchant()">进入管理</button>
                    </div>
                    <div class="card">
                        <div class="card-icon">📦</div>
                        <h3>订单处理</h3>
                        <p>实时接收订单，处理配送安排</p>
                        <div class="card-stats">
                            <span>实时提醒</span>
                            <span>快速处理</span>
                        </div>
                    </div>
                    <div class="card">
                        <div class="card-icon">📊</div>
                        <h3>经营数据</h3>
                        <p>查看销售统计、收益分析和客户反馈</p>
                        <div class="card-stats">
                            <span>收益分析</span>
                            <span>销售统计</span>
                        </div>
                    </div>
                    <div class="card">
                        <div class="card-icon">⚙️</div>
                        <h3>店铺设置</h3>
                        <p>管理店铺信息、营业时间和配送范围</p>
                        <div class="card-stats">
                            <span>营业时间</span>
                            <span>配送范围</span>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- 骑手端 -->
        <section id="rider" class="section">
            <div class="login-prompt" id="riderLoginPrompt">
                <h2>骑手端</h2>
                <p>请先登录以使用骑手功能</p>
                <div class="login-buttons">
                    <button class="btn btn-primary btn-large" onclick="goToLogin()">登录</button>
                    <button class="btn btn-primary btn-large" onclick="goToRegister()">注册</button>
                </div>
            </div>
            
            <div id="riderContent" class="hidden">
                <div class="user-welcome">
                    <h2>🏍️ 骑手端</h2>
                    <p>欢迎，<span id="riderDisplayName"></span>！开始您的配送工作</p>
                </div>
                
                <div class="grid">
                    <div class="card">
                        <div class="card-icon">📋</div>
                        <h3>接单配送</h3>
                        <p>查看附近订单，选择配送任务</p>
                        <div class="card-stats">
                            <span>订单提醒</span>
                            <span>一键接单</span>
                        </div>
                        <button class="btn btn-primary" onclick="goToRider()">进入骑手中心</button>
                    </div>
                    <div class="card">
                        <div class="card-icon">🗺️</div>
                        <h3>地图导航</h3>
                        <p>智能路线规划，实时导航指引</p>
                        <div class="card-stats">
                            <span>最优路线</span>
                            <span>实时定位</span>
                        </div>
                    </div>
                    <div class="card">
                        <div class="card-icon">💰</div>
                        <h3>收益统计</h3>
                        <p>查看每日收益、配送统计和提现</p>
                        <div class="card-stats">
                            <span>实时收益</span>
                            <span>数据统计</span>
                        </div>
                    </div>
                    <div class="card">
                        <div class="card-icon">👤</div>
                        <h3>个人中心</h3>
                        <p>管理个人信息、工作状态和评价</p>
                        <div class="card-stats">
                            <span>用户评价</span>
                            <span>个人设置</span>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <script>
        let currentUser = null;
        
        // 页面加载时检查登录状态
        window.onload = function() {
            checkLoginStatus();
            // 检查URL参数
            const hash = window.location.hash;
            if (hash === '#user' || hash === '#merchant' || hash === '#rider') {
                const sectionId = hash.substring(1);
                showSection(sectionId);
            }
        };
        
        function checkLoginStatus() {
            const savedUser = localStorage.getItem('currentUser');
            if (savedUser) {
                currentUser = JSON.parse(savedUser);
                showUserInfo();
                showUserContent();
            } else {
                showLoginPrompts();
            }
        }
        
        function showUserInfo() {
            if (currentUser) {
                document.getElementById('userName').textContent = currentUser.name || currentUser.username;
                document.getElementById('userInfo').style.display = 'flex';
            }
        }
        
        function showUserContent() {
            if (!currentUser) return;
            
            // 隐藏所有登录提示
            document.querySelectorAll('[id$="LoginPrompt"]').forEach(el => {
                el.classList.add('hidden');
            });
            
            // 隐藏所有用户内容
            document.querySelectorAll('[id$="Content"]').forEach(el => {
                el.classList.add('hidden');
            });
            
            // 显示对应用户类型的内容
            if (currentUser.type === 'user') {
                document.getElementById('userContent').classList.remove('hidden');
                document.getElementById('userDisplayName').textContent = currentUser.name || currentUser.username;
            } else if (currentUser.type === 'merchant') {
                document.getElementById('merchantContent').classList.remove('hidden');
                document.getElementById('merchantDisplayName').textContent = currentUser.name || currentUser.username;
            } else if (currentUser.type === 'rider') {
                document.getElementById('riderContent').classList.remove('hidden');
                document.getElementById('riderDisplayName').textContent = currentUser.name || currentUser.username;
            }
        }
        
        function showLoginPrompts() {
            // 显示所有登录提示
            document.querySelectorAll('[id$="LoginPrompt"]').forEach(el => {
                el.classList.remove('hidden');
            });
            
            // 隐藏所有用户内容
            document.querySelectorAll('[id$="Content"]').forEach(el => {
                el.classList.add('hidden');
            });
        }
        
        function showSection(sectionId) {
            // 检查权限
            if (sectionId !== 'home') {
                if (!currentUser) {
                    alert('请先登录！');
                    return;
                }
                if (currentUser.type !== sectionId) {
                    alert(`您没有权限访问${sectionId === 'user' ? '用户' : sectionId === 'merchant' ? '商家' : '骑手'}端界面！`);
                    return;
                }
            }
            
            // 如果用户已登录且访问对应界面，直接显示内容
            if (currentUser && currentUser.type === sectionId) {
                showUserContent();
            }
            
            // 隐藏所有section
            document.querySelectorAll('.section').forEach(section => {
                section.classList.remove('active');
            });
            
            // 显示选中的section
            document.getElementById(sectionId).classList.add('active');
            
            // 更新导航链接状态
            document.querySelectorAll('.nav-link').forEach(link => {
                link.classList.remove('active');
            });
            document.querySelector(`[href="#${sectionId}"]`).classList.add('active');
        }
        
        function goToLogin() {
            window.location.href = 'auth.html';
        }
        
        function goToRegister() {
            window.location.href = 'auth.html';
        }
        
        function goToDishManage() {
            window.location.href = 'dish-manage.html';
        }
        
        function goToMerchant() {
            window.location.href = 'merchant.html';
        }
        
        function goToUser() {
            window.location.href = 'user.html';
        }
        
        function goToRider() {
            window.location.href = 'rider.html';
        }
        
        function logout() {
            localStorage.removeItem('currentUser');
            currentUser = null;
            document.getElementById('userInfo').style.display = 'none';
            showLoginPrompts();
            showSection('home');
        }
        
        function goBack() {
            window.location.href = 'start.html';
        }
    </script>
</body>
</html>
